package com.oa.common.utils;

import cn.hutool.core.codec.Base64;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import lombok.extern.log4j.Log4j2;

import java.util.HashMap;
import java.util.Map;

@Log4j2
public class SmsUtil {

    public static Map sendSms(String mobiles, String content) {
        HashMap<String, String> smsMap = new HashMap<>();
        smsMap.put("ecName", "齐河县政务服务中心");
        smsMap.put("apId", "qhxdx");
        smsMap.put("mobiles", mobiles);
        smsMap.put("content", content);
        smsMap.put("sign", "eFt3x0bdo");
        smsMap.put("addSerial", "");
        String originalMac = smsMap.get("ecName") + smsMap.get("apId") + "@WSX1qaz" + smsMap.get("mobiles") + smsMap.get("content") + smsMap.get("sign");
        String encryption = MD5Util.encryption(originalMac);
        smsMap.put("mac", encryption);
        Gson gson = new Gson();
        String json = gson.toJson(smsMap);
        log.error(json);
        String encode = Base64.encode(json);
        String body = HttpRequest.post("http://112.35.1.155:1992/sms/norsubmit")
                .body(encode)
                .execute().body();
        log.error(body);
        Map response= gson.fromJson(body, Map.class);
        return response;
    }

    public static void main(String[] args) {
        Map map = sendSms("17663609319", "齐河审批局邀请您加入视频会议，房间号：734983 ,请前往爱山东-e齐办应用进入会议");
        System.out.println(map);
    }

}
